package com.example.smart.adapter.home

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.example.lib.extend.setOnDoubleClickListener
import com.example.smart.R
import com.example.smart.base.adapter.BaseRecyclerAdapter
import com.example.smart.base.adapter.BaseViewHolder
import com.example.smart.data.MenuData
import com.example.smart.databinding.ItemMenuMBinding

class MMenuAdapter(context: Context) : BaseRecyclerAdapter<ItemMenuMBinding, MenuData>(context) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ItemMenuMBinding> {
        return BaseViewHolder(ItemMenuMBinding.bind(LayoutInflater.from(context)
            .inflate(R.layout.item_menu_m, parent, false)))
    }

    override fun onBindView(itemView: ItemMenuMBinding, bean: MenuData, position: Int) {
        itemView.ItemImage.setImageResource(bean.image)
        itemView.ItemText.setImageResource(bean.titleImage)
        itemView.root.setOnDoubleClickListener {
            clickListener?.click(bean, position)
        }
    }
}